cmake_minimum_required(VERSION 2.6)
project(WoW)

###############################################################################
if (MSVC)
set(CMAKE_C_FLAGS_DEBUG "-W3 -D_CRT_SECURE_NO_WARNINGS")
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
elseif (UNIX)
set(CMAKE_C_FLAGS_DEBUG "-g -Wall")
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-deprecated-declarations -Wno-reorder -Wwrite-strings")
endif()

###############################################################################
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})

set(BOOST_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/deps/boost")
set(BOOST_FOUND TRUE)
add_subdirectory(deps/tinyxml)
set(TINYXML_FOUND TRUE)
add_subdirectory(deps/zlib)
set(UTF8CPP_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/deps/utf8cpp")
set(UTF8CPP_FOUND TRUE)

if (MSVC)
    # LIBEVENT
    set(LIBEVENT_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/deps/libevent/include")
    set(LIBEVENT_LIBRARY_DIR "${PROJECT_SOURCE_DIR}/deps/libevent/lib")
    set(LIBEVENT_LIBRARY "libevent")
    set(LIBEVENT_FOUND TRUE)
    # MYSQL
    set(MYSQL_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/deps/mysql/include")
    set(MYSQL_LIBRARY_DIR "${PROJECT_SOURCE_DIR}/deps/mysql/lib")
    set(MYSQL_LIBRARY "libmysql")
    set(MYSQL_FOUND TRUE)
    # OPENSSL
    set(OPENSSL_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/deps/openssl/")
    set(OPENSSL_LIBRARY_DIR "${PROJECT_SOURCE_DIR}/deps/openssl/lib")
    set(OPENSSL_LIBRARY "libeay32")
    set(OPENSSL_FOUND TRUE)
elseif(UNIX)
    find_package(LIBEVENT)
    if (NOT LIBEVENT_FOUND)
        message(FATAL_ERROR "can not found libevent")
    endif()
    
    find_package(MYSQL)
    if (NOT MYSQL_FOUND)
        message(FATAL_ERROR "can not found mysql")
    endif()
    
    find_package(OPENSSL)
    if (NOT OPENSSL_FOUND)
        message(FATAL_ERROR "can not found openssl")
    endif()
endif()
add_subdirectory(deps/NodeCpp)

###############################################################################
include_directories(
    "${PROJECT_SOURCE_DIR}"
    "${PROJECT_SOURCE_DIR}/deps/NodeCpp"
    "${LIBEVENT_INCLUDE_DIR}"
    "${BOOST_INCLUDE_DIR}"
    "${MYSQL_INCLUDE_DIR}"
    "${TINYXML_INCLUDE_DIR}"
    "${ZLIB_INCLUDE_DIR}"
    "${OPENSSL_INCLUDE_DIR}"
    "${UTF8CPP_INCLUDE_DIR}"
)
link_directories(
    "${LIBEVENT_LIBRARY_DIR}"
    "${MYSQL_LIBRARY_DIR}"
    "${OPENSSL_LIBRARY_DIR}"
)
###############################################################################
add_subdirectory(Shared)
add_subdirectory(Realmd)
add_subdirectory(Game)
